﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;

namespace Spike.ServiceFramework.ServiceModel.Registration
{
    public class ClientApplication : ConfigurationElement
    {
        [ConfigurationProperty("name", IsKey = true, IsRequired = true)]
        public string Name
        {
            set { base["name"] = value; }
            get { return (string)this["name"]; }
        }

        [ConfigurationProperty("version", IsKey = true, IsRequired = true)]
        public string Version
        {
            set { base["version"] = value; }
            get { return (string)this["version"]; }
        }
        
        public Guid CorrelationID { get; set; }
    }

    public class ClientApplicationElementCollection : ConfigurationElementCollection
    {
        public void AddAccess(ClientApplication application)
        {
            this.BaseAdd(application);
        }

        protected override ConfigurationElement CreateNewElement()
        {
            return new ClientApplication();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((ClientApplication)element).Name;
        }
    }
}
